﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工资管理</title>
<#--<%@include file="/WEB-INF/views/common/link.jsp"%>-->
<#--freemarker的nclude 包含另一个文件模板 需要使用相对模板文件路径-->
    <#include "../common/link.ftl">
    <script src="/js/plugins/messager/jquery.bootstrap.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<#--<%@include file="/WEB-INF/views/common/navbar.jsp"%>-->
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
<#--<c:set var="currentMenu" value="salary"/>-->
<#--使用freemarker标签定义变量-->
    <#assign currentMenu="salary"/>
<#--<%@include file="/WEB-INF/views/common/menu.jsp"%>-->
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>工资管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/salary/list.do" method="post">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                               placeholder="请输入姓名/电话">
                    </div>
                    <@shiro.hasAnyRoles name="ADMIN,Market_Manager">
                    <div class="form-group">
                        <label for="dept"> 发放方式:</label>
                        <select class="form-control" id="payout" name="payoutId">
                            <option value="-1">全部</option>
                                <#list payout as s>
                                    <option value="${s.id}">${s.name}</option>
                                </#list>
                        </select>
                        <script>
                            $("#payout option[value='${qo.payoutId!}']").prop("selected", true);
                        </script>
                    </div>
                    </@shiro.hasAnyRoles>

                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span>查询
                    </button>
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>年份</th>
                            <th>月份</th>
                            <th>员工</th>
                            <th>工资</th>
                            <th>发放方式</th>
                            <th>操作</th>
                        </tr>
                        <#list pageInfo.list as salary>
                            <tr>
                                <td>${salary_index+1}</td>
                                <td>${salary.year!}</td>
                                <td>${salary.month!}</td>
                                <td>${salary.employee.id!}</td>
                                <td>${(salary.money)!}</td>
                                <td>${(salary.payoutId)!}</td>
                            <#--不能直接显示日期类型的数据,必须要指定格式-->
                                <td>${(salary.inputTime?string('yyyy-MM-dd'))!}</td>
                                <td>
                                    <!--使用data-*绑定自定义数据-->
                                    <a href="#" class="btn btn-info btn-xs btn-input" data-json='${salary.json!}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                </td>
                            </tr>
                        </#list>

                    </table>
                    <!--分页-->
                    <div style="text-align: center">
                        <ul id="pagination" class="pagination"></ul>
                    </div>
                    <script>
                        $(function () {
                            $('#pagination').twbsPagination({
                                totalPages: ${pageInfo.pages},
                                startPage: ${pageInfo.pageNum},
                                visiblePages: 5,
                                first: "首页",
                                prev: "上页",
                                next: "下页",
                                last: "尾页",
                                initiateStartPageClick: false,
                                onPageClick: function (event, page) { //点击页码的时候会执行的方法
                                    $("#currentPage").val(page);
                                    $("#searchForm").submit();
                                }
                            });
                        })
                    </script>
                </div>
            </div>
        </section>
    </div>
<#--<%@include file="/WEB-INF/views/common/footer.jsp"%>-->
    <#include "../common/footer.ftl">
</div>
-- <!--bootstrap模态框-->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title inputTitle">工资管理新增/编辑</h4>
            </div>
            <form class="form-horizontal" action="/salary/saveOrUpdate.do" method="post" id="editForm">
                <div class="modal-body">
                    <input type="hidden" name="id">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">年份：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="year" name="year">
                                <option value="DATE_FORMAT(c.input_time, '%Y')">年</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">月份：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="month" name="month">
                                <option value="DATE_FORMAT(c.input_time, '%Y-%m')">月</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">员工：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="employeeId"
                                   placeholder="请输入员工姓名"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">工资：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="money"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">发放方式：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="payout.id">
                                <#list sources as s>
                                    <option value="${s.id}">${s.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary btn-submit">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>

    $(function () {
        //调用模态框
        $('.btn-input').click(function () {
            $('#editModal').modal('show');
        });
        //添加
        $('.btn-submit').click(function () {
            $('#editForm').ajaxSubmit(handlerMessager);
        })
        //修改
        $(".btn-input").click(function () {
            //清除模态框数据
            $("#editForm input").val('');
            //获取事件源绑定的数据 使用data方法可以很方便获取data-*开头的属性的数据
            var json = $(this).data("json");
            if (json) {
                //回显
                $("#editModal input[name=id]").val(json.id);
                $("#editModal select[name=year]").val(json.gender);
                $("#editModal select[name=month]").val(json.gender);
                $("#editModal input[name=name]").val(json.name);
                $("#editModal input[name=money]").val(json.money);
                $("#editModal select[name='job.id']").val(json.jobId);
                $("#editModal select[name='source.id']").val(json.sourceId);
            }
            $("#editModal").modal("show");
        });



    }) //初始化日期插件
    $("input[name=traceTime]").datepicker({
        clearBtn:true,
        language: "zh-CN", //语言
        autoclose: true, //选择日期后自动关闭
        todayHighlight: true //高亮今日日期
    });
</script>
</body>
</html>
